/**
 */
package moore.impl;

import moore.MoorePackage;
import moore.OutputConfiguration;
import moore.valueState;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Output Configuration</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link moore.impl.OutputConfigurationImpl#getValue <em>Value</em>}</li>
 *   <li>{@link moore.impl.OutputConfigurationImpl#getOutputFor <em>Output For</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class OutputConfigurationImpl extends AbstractElementImpl implements OutputConfiguration {
	/**
	 * The default value of the '{@link #getValue() <em>Value</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getValue()
	 * @generated
	 * @ordered
	 */
	protected static final String VALUE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getValue() <em>Value</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getValue()
	 * @generated
	 * @ordered
	 */
	protected String value = VALUE_EDEFAULT;

	/**
	 * The cached value of the '{@link #getOutputFor() <em>Output For</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOutputFor()
	 * @generated
	 * @ordered
	 */
	protected valueState outputFor;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected OutputConfigurationImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return MoorePackage.Literals.OUTPUT_CONFIGURATION;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getValue() {
		return value;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setValue(String newValue) {
		String oldValue = value;
		value = newValue;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, MoorePackage.OUTPUT_CONFIGURATION__VALUE, oldValue, value));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public valueState getOutputFor() {
		if (outputFor != null && outputFor.eIsProxy()) {
			InternalEObject oldOutputFor = (InternalEObject)outputFor;
			outputFor = (valueState)eResolveProxy(oldOutputFor);
			if (outputFor != oldOutputFor) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, MoorePackage.OUTPUT_CONFIGURATION__OUTPUT_FOR, oldOutputFor, outputFor));
			}
		}
		return outputFor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public valueState basicGetOutputFor() {
		return outputFor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetOutputFor(valueState newOutputFor, NotificationChain msgs) {
		valueState oldOutputFor = outputFor;
		outputFor = newOutputFor;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MoorePackage.OUTPUT_CONFIGURATION__OUTPUT_FOR, oldOutputFor, newOutputFor);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setOutputFor(valueState newOutputFor) {
		if (newOutputFor != outputFor) {
			NotificationChain msgs = null;
			if (outputFor != null)
				msgs = ((InternalEObject)outputFor).eInverseRemove(this, MoorePackage.VALUE_STATE__OUPUT_VALUE, valueState.class, msgs);
			if (newOutputFor != null)
				msgs = ((InternalEObject)newOutputFor).eInverseAdd(this, MoorePackage.VALUE_STATE__OUPUT_VALUE, valueState.class, msgs);
			msgs = basicSetOutputFor(newOutputFor, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, MoorePackage.OUTPUT_CONFIGURATION__OUTPUT_FOR, newOutputFor, newOutputFor));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case MoorePackage.OUTPUT_CONFIGURATION__OUTPUT_FOR:
				if (outputFor != null)
					msgs = ((InternalEObject)outputFor).eInverseRemove(this, MoorePackage.VALUE_STATE__OUPUT_VALUE, valueState.class, msgs);
				return basicSetOutputFor((valueState)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case MoorePackage.OUTPUT_CONFIGURATION__OUTPUT_FOR:
				return basicSetOutputFor(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case MoorePackage.OUTPUT_CONFIGURATION__VALUE:
				return getValue();
			case MoorePackage.OUTPUT_CONFIGURATION__OUTPUT_FOR:
				if (resolve) return getOutputFor();
				return basicGetOutputFor();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case MoorePackage.OUTPUT_CONFIGURATION__VALUE:
				setValue((String)newValue);
				return;
			case MoorePackage.OUTPUT_CONFIGURATION__OUTPUT_FOR:
				setOutputFor((valueState)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case MoorePackage.OUTPUT_CONFIGURATION__VALUE:
				setValue(VALUE_EDEFAULT);
				return;
			case MoorePackage.OUTPUT_CONFIGURATION__OUTPUT_FOR:
				setOutputFor((valueState)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case MoorePackage.OUTPUT_CONFIGURATION__VALUE:
				return VALUE_EDEFAULT == null ? value != null : !VALUE_EDEFAULT.equals(value);
			case MoorePackage.OUTPUT_CONFIGURATION__OUTPUT_FOR:
				return outputFor != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (value: ");
		result.append(value);
		result.append(')');
		return result.toString();
	}

} //OutputConfigurationImpl
